﻿using System.Data;
using System.Linq;
using System.Web.Mvc;
using GioHangViet.Models;

namespace GioHangViet.Areas.Admin.Controllers
{ 
    public class CommentController : Controller
    {
        private GoLungTungModel db = new GoLungTungModel();

        //
        // GET: /Admin/Comment/

        public ViewResult Index()
        {
            return View(db.ProductComments.ToList());
        }

        //
        // GET: /Admin/Comment/Details/5

        public ViewResult Details(int id)
        {
            ProductComment productcomment = db.ProductComments.Find(id);
            return View(productcomment);
        }

        public ViewResult Approved(int id)
        {
            ProductComment productcomment = db.ProductComments.Find(id);
            return View(productcomment);
        }
        //
        // GET: /Admin/Comment/Edit/5
 
        public ActionResult Edit(int id)
        {
            ProductComment productcomment = db.ProductComments.Find(id);
            return View(productcomment);
        }

        //
        // POST: /Admin/Comment/Edit/5

        [HttpPost]
        public ActionResult Edit(ProductComment productcomment)
        {
            if (ModelState.IsValid)
            {
                db.Entry(productcomment).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(productcomment);
        }

        //
        // GET: /Admin/Comment/Delete/5
 
        public ActionResult Delete(int id)
        {
            ProductComment productcomment = db.ProductComments.Find(id);
            return View(productcomment);
        }

        //
        // POST: /Admin/Comment/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {            
            ProductComment productcomment = db.ProductComments.Find(id);
            db.ProductComments.Remove(productcomment);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}